$(function(){			

	if ($('html').hasClass('csstransforms3d')) {

		var foldingList = $('.folding'),
			foldingListHeight = $('.folding').height();
			topElemOffset = foldingList.offset().top,
			// Function responsible for unfolding the list
			unfold = function(){
				setTimeout(function(){
					if (foldingList.hasClass('folded')){
						foldingList.removeClass('folded');
						return;
					}
				}, 500);
			}

		// Fold/Unfold the list
		$('.connect').on("click",function(){
			foldingList.toggleClass('folded');
		})
		// If needed, unfold the list right away
		if (topElemOffset <= $(window).height() - foldingListHeight)
			unfold();
		// Check whether to unfold the list when scrolling/resizing
		$(window).on("scroll resize", function(){
			var th = $(this);				
			if (th.scrollTop() + th.height() - foldingListHeight  >=  topElemOffset)
				unfold();				
		})
	}

})()